﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Data;

namespace My.Utils
{
    public class RegexUtil
    {
        public static Match GetMatch(string pattern, string input)
        {
            Regex regex=new Regex(pattern,RegexOptions.IgnoreCase);
			Match m=regex.Match(input);
            if (m.Success)
            {
                return m;
            }
            else {
                return null;
            }
        }

        public static MatchCollection GetMatches(string parttern, string input) {
            MatchCollection mc = Regex.Matches(input, parttern, RegexOptions.IgnoreCase);
            return mc;
        
        }

        public static bool IsEmail(string input) {
            string pattern = @"[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}";
            return GetMatch(pattern, input)!=null;
        }
    }
}
